<?php


namespace app\model;

use think\Model;
class Attachment extends Model
{
    protected $table = "store_attachment";

    /**
     * @param $table_name
     * @param $table_id
     * @return Attachment[]|array|\think\Collection
     * @notes 附件
     * @author: dongdong
     * @date: 2025/1/8 15:11
     */
    public function info($table_name,$table_id){
        try {
            return self::where(["table_id"=>$table_id,"table_name"=>$table_name])->field("id,path")->select();
        }catch (\Exception $e){
            return [];
        }
    }

    /**
     * @param $table_name
     * @param $ids
     * @return Attachment[]|array|\think\Collection
     * @notes 附件列表
     * @author: dongdong
     * @date: 2025/2/12 9:48
     */
    public function lists($table_name,$ids){
        try {
            return self::where(["table_name"=>$table_name])->where("id","in",$ids)->field("id,path")->select();
        }catch (\Exception $e){
            return [];
        }
    }

}